package com.bhs.sansong.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansong.R;
import com.bhs.sansong.bean.LogisticsMode;
import com.bhs.sansong.utils.LogUtils;
import com.bhs.sansong.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * 物流方式
 */
public class LogisticsModeAdapter extends BaseQuickAdapter<LogisticsMode, BaseViewHolder> {

    Activity activity;

    public LogisticsModeAdapter(@Nullable List<LogisticsMode> data, Activity activity) {
        super(R.layout.item_logistics_mode, data);
        this.activity=activity;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, LogisticsMode item) {
        TextView tv_mode = helper.getView(R.id.tv_mode);
        TextView tvNumberDays = helper.getView(R.id.tv_number_days);
        TextView tvMoney = helper.getView(R.id.tv_money);
        LinearLayout llBargain = helper.getView(R.id.ll_bargain);
        tv_mode.setText(MyUtils.getDeliverType(item.getMode()));
        ImageView ivWrite= helper.getView(R.id.iv_write);
        TextView etBargain= helper.getView(R.id.et_bargain);
        View view= helper.getView(R.id.view);
        if (!TextUtils.isEmpty(item.getPrice())&&!item.getPrice().equals("0")) {
            tvNumberDays.setText(String.format("约%s-%s天", item.getMinimumDays(), item.getMaximumDays()));
            tvMoney.setText(String.format("￥%s", item.getPrice()));
            tvMoney.setVisibility(View.VISIBLE);
            llBargain.setVisibility(View.GONE);
        } else {
            tvNumberDays.setText("价更优,可出价");
            tvMoney.setVisibility(View.GONE);
            llBargain.setVisibility(View.VISIBLE);
        }

        if (item.isCheck()) {
            helper.setBackgroundRes(R.id.ll_main, R.drawable.border_blue_8);
            tv_mode.setBackgroundResource(R.drawable.bg_single);
            tv_mode.setTextColor(Color.parseColor("#ffffff"));
            tvNumberDays.setTextColor(Color.parseColor("#000000"));
            tvMoney.setTextColor(Color.parseColor("#FF6067"));
            helper.setBackgroundRes(R.id.tv_hint, R.drawable.bg_blue_bottom);
            ivWrite.setImageResource(R.mipmap.ic_write_blue);
            etBargain.setHintTextColor(Color.parseColor("#485EF4"));
            view.setBackgroundColor(Color.parseColor("#485EF4"));
        } else {
            helper.setBackgroundRes(R.id.ll_main, R.drawable.border_grey_8);
            tv_mode.setBackgroundResource(R.drawable.bg_grey_card);
            tv_mode.setTextColor(Color.parseColor("#000000"));
            tvNumberDays.setTextColor(Color.parseColor("#909399"));
            tvMoney.setTextColor(Color.parseColor("#909399"));
            helper.setBackgroundRes(R.id.tv_hint, R.drawable.bg_grey_bottom);
            ivWrite.setImageResource(R.mipmap.ic_write);
            etBargain.setHintTextColor(Color.parseColor("#909399"));
            view.setBackgroundColor(Color.parseColor("#909399"));
        }

    }
}
